//
//  InPlayer.h
//  InPlayer
//
//  Created by qianjianeng on 16/1/31.
//  Copyright © 2016年 SF. All rights reserved.
//


#import <AVFoundation/AVFoundation.h>
#import <UIKit/UIKit.h>

@protocol lastBtnChange <NSObject>

- (void)lastBtnTypeChange;

- (void)nexBtnTypeChange;

@end

FOUNDATION_EXPORT NSString *const kInPlayerStateChangedNotification;
FOUNDATION_EXPORT NSString *const kInPlayerProgressChangedNotification;
FOUNDATION_EXPORT NSString *const kInPlayerLoadProgressChangedNotification;

//播放器的几种状态
typedef NS_ENUM(NSInteger, InPlayerState) {
    InPlayerStateBuffering = 1,
    InPlayerStatePlaying   = 2,
    InPlayerStateStopped   = 3,
    InPlayerStatePause     = 4
};

@interface InPlayer : NSObject

@property (nonatomic, readonly) InPlayerState state;
@property (nonatomic, readonly) CGFloat       loadedProgress;   //缓冲进度
@property (nonatomic, readonly) CGFloat       duration;         //视频总时间
@property (nonatomic, readonly) CGFloat       current;          //当前播放时间
@property (nonatomic, readonly) CGFloat       progress;         //播放进度 0~1

@property (nonatomic, strong) UISlider       *playSlider;  //滑竿

@property (nonatomic, strong) AVPlayerItem   *currentPlayerItem;

@property (nonatomic, strong) AVPlayerLayer  *currentPlayerLayer;

@property (weak,nonatomic)id<lastBtnChange>detegate;

@property (nonatomic          ) BOOL          stopWhenAppDidEnterBackground;// default is YES


+ (instancetype)sharedInstance;
- (void)playWithUrl:(NSURL *)url showView:(UIView *)showView;
- (void)seekToTime:(CGFloat)seconds;

- (void)resume;
- (void)pause;
- (void)stop;

@end
